package com.atguigu.spzx.product.controller;

import com.atguigu.spzx.model.common.Result;
import com.atguigu.spzx.model.vo.h5.IndexVo;
import com.atguigu.spzx.product.service.ProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/product/index")
//@CrossOrigin(originPatterns = "*" , allowCredentials = "true")
@Tag(name = "用户端首页模块")
public class IndexController {
    @Resource
    ProductService productService;
    //分类：只查一级分类       畅销商品： 查询销量前8的商品列表
    @Operation(summary = "查询首页分类列表和畅销商品列表数据")
    @GetMapping
    public Result index(){
        IndexVo indexVo = productService.findCatesAndSkus();
        return Result.ok().data(indexVo);
    }
}
